Skip to content

Read instance variables directly instead of evaluating Ruby source - #95

Open
OskarEichler wants to merge 1 commit into
ruby:masterfrom
OskarEichler:codex/read-instance-variables-directly
Open

Read instance variables directly instead of evaluating Ruby source#95
OskarEichler wants to merge 1 commit into
ruby:masterfrom
OskarEichler:codex/read-instance-variables-directly

Conversation

@OskarEichler

Copy link
Copy Markdown

Summary

Read listed instance variables through the core getter, using PP.mcall, instead of compiling Ruby source with instance_eval. Objects overriding instance_eval currently print the override's result instead of their stored variable values.

Reproduction and verification

An Object with @x=123 and an instance_eval override returning :wrong currently renders @x=:wrong. Also checked overridden instance_variable_get, mixed symbol/string names, missing/nil/false variables and Unicode names across 500 objects. Local five-sample benchmark, 200 renders of 30 variables: about 16–21ms before, 6.4ms after; Ruby allocations roughly unchanged. No application-throughput claim.

  • Isolated branch: 3,004 focused checks pass under rbenv Ruby 4.0.6.
  • Existing upstream RBENV_VERSION=4.0.6 rbenv exec rake test: 36 tests / 56 assertions, zero failures before and after.
  • 2,000 ordinary single-/multi-line outputs remain byte-identical.
  • Source-only change; no test files added or modified under the contributor's task constraint. Focused scripts are outside the repository. Other Ruby engines/versions and native Windows were not executed.

Breaking-change notes

Listed names continue to mean instance-variable names. Core storage reads now ignore overrides of instance_eval/instance_variable_get; custom presentation belongs in pretty_print. Normal output is unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant